home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 11 / Mac Magazin and MacEasy Magazine CD - Issue 11.iso / Sharewarebibliothek / Entwickler / WASTE 1.1b1 Distribution / WASTE Source / WEInterface.p < prev    next >
Text File  |  1995-06-01  |  25KB  |  804 lines

  1. unit WEInterface;
  2.  
  3. { WASTE PROJECT: }
  4. { Internal interface: private constants and data types }
  5.  
  6. { Copyright © 1993-1995 Marco Piovanelli }
  7. { All Rights Reserved }
  8.  
  9. interface
  10.     uses
  11.         ConditionalMacros, Types, Memory, Fonts, Quickdraw, QuickdrawText, Script, TextUtils, TextServices, Drag, WELongCoords, WEUtilities;
  12.  
  13. { compiler switches }
  14.  
  15. { set WASTE_DEBUG to TRUE to perform miscellaneous asserts and sanity checks }
  16.  
  17. {$IFC UNDEFINED WASTE_DEBUG}
  18. {$SETC WASTE_DEBUG = FALSE}
  19. {$ENDC}
  20.  
  21. { set WASTE_SEGMENT to TRUE to build a multi-segment library }
  22. { using the $S segmentation directive }
  23.  
  24. {$IFC UNDEFINED WASTE_SEGMENT}
  25. {$SETC WASTE_SEGMENT = FALSE}
  26. {$ENDC}
  27.  
  28.     const
  29.  
  30. { result codes }
  31.  
  32.         weCantUndoErr = -10015;                        { undo buffer is clear (= errAECantUndo) }
  33.         weEmptySelectionErr = -10013;                { empty selection range (= errAENoUserSelection) }
  34.         weUnknownObjectTypeErr = -9478;            { specified object type was not registered }
  35.         weObjectNotFoundErr = -9477;                    { no object found at specified offset }
  36.         weReadOnlyErr = -9476;                            { instance is read-only }
  37.  
  38. { alignment styles }
  39.  
  40.         weFlushLeft = -2;
  41.         weFlushRight = -1;
  42.         weFlushDefault = 0;
  43.         weCenter = 1;
  44.         weJustify = 2;
  45.  
  46. { values for the edge parameter }
  47.  
  48.         kLeadingEdge = -1;                { point is on the leading edge of a glyph }
  49.         kTrailingEdge = 0;                    { point is on the trailing edge of a glyph }
  50.         kObjectEdge = 2;                    { point is inside an embedded object }
  51.  
  52. { control character codes }
  53.  
  54.         kObjectMarker = 1;
  55.         kBackspace = 8;
  56.         kTab = 9;
  57.         kEOL = 13;
  58.         kSpace = 32;
  59.         kArrowLeft = 28;
  60.         kArrowRight = 29;
  61.         kArrowUp = 30;
  62.         kArrowDown = 31;
  63.         kForwardDelete = 127;
  64.  
  65. { bit equates for QuickDraw styles }
  66.  
  67.         tsBold = 0;
  68.         tsItalic = 1;
  69.         tsUnderline = 2;
  70.         tsOutline = 3;
  71.         tsShadow = 4;
  72.         tsCondense = 5;
  73.         tsExtend = 6;
  74.  
  75. { bit equates for the tsFlags field of the WETextStyle record }
  76.  
  77.         tsTSMHilite = 4;                            { set if style run is part of active input area }
  78.         tsTSMSelected = 5;                        { set for selected raw/converted text }
  79.         tsTSMConverted = 6;                        { set for converted text, clear for raw text }
  80.         tsRightToLeft = 7;                            { specifies style run direction }
  81.  
  82. { bit equates for the mode parameter in WESetStyle and WEContinuousStyle }
  83.  
  84.         kModeFont = 0;
  85.         kModeFace = 1;
  86.         kModeSize = 2;
  87.         kModeColor = 3;
  88.         kModeAddSize = 4;
  89.         kModeToggleFace = 5;
  90.         kModeReplaceFace = 6;
  91.         kModeObject = 14;
  92.         kModeFlags = 15;
  93.  
  94. { values for the mode parameter in WESetStyle and WEContinuousStyle }
  95.  
  96.         weDoFont = $0001;
  97.         weDoFace = $0002;
  98.         weDoSize = $0004;
  99.         weDoColor = $0008;
  100.         weDoAll = weDoFont + weDoFace + weDoSize + weDoColor;
  101.         weDoAddSize = $0010;
  102.         weDoToggleFace = $0020;
  103.         weDoReplaceFace = $0040;
  104.         weDoObject = $4000;
  105.         weDoFlags = $8000;
  106.  
  107. { values for WEFeatureFlag action parameter }
  108.  
  109.         weBitToggle = -2;                            { toggles the specified feature }
  110.         weBitTest = -1;                                { returns the current setting of the specified feature }
  111.         weBitClear = 0;                                { disables the specified feature }
  112.         weBitSet = 1;                                { enables the specified feature }
  113.  
  114. { bit equates for the flags field in the WE record }
  115. { bits 0..15 can be used to turn on and off specific features with WEFeatureFlag }
  116. { bits 16..31 are used internally and should not be modified }
  117.  
  118.         weFHasColorQD = 31;                    { Color QuickDraw is available }
  119.         weFHasTextServices = 30;                { Text Services Manager is available }
  120.         weFNonRoman = 29;                        { At least one non-Roman script is enabled }
  121.         weFDoubleByte = 28;                    { A double-byte script is installed }
  122.         weFHasDragManager = 27;            { Drag Manager is available }
  123.         weFCaretVisible = 24;                    { Caret is currently visible }
  124.         weFMouseTracking = 23;                { Set internally during mouse tracking }
  125.         weFAnchorIsEnd = 22;                    { Anchor offset is selEnd }
  126.         weFUseNullStyle = 21;                    { A null style is associated with the empty selection }
  127.         weFActive = 20;                            { TRUE if text pane is active }
  128.         weFHilited = 19;                            { TRUE if text pane is highlighted (for Drag & Drop) }
  129.         weFCanAcceptDrag = 18;                { The drag in the text pane can be accepted }
  130.         weFDragCaretVisible = 17;            { Drag caret is currently visible }
  131.         weFDestRectChanged = 16;            { Set if scroll callback needs to be called }
  132.  
  133.         weFDrawOffscreen = 11;                { Draw text offscreen for smoother visual results }
  134.         weFUseTempMem = 10;                { Use temporary memory }
  135.         weFInhibitRecal = 9;                        { If set, recals and redraws are inhibited }
  136.         weFDragAndDrop = 8;                    { Support Drag and Drop }
  137.         weFIntCutAndPaste = 7;                { Intelligent Cut & Paste }
  138.         weFUndoSupport = 6;                    { Support Undo/Redo }
  139.         weFReadOnly = 5;                            { Disallow editing }
  140.         weFOutlineHilite = 2;                    { Outline selection range when text pane is inactive }
  141.         weFAutoScroll = 0;                        { Automatically scroll text when cursor is outside pane }
  142.  
  143. { scrap types }
  144.  
  145.         kTypeText = 'TEXT';
  146.         kTypeStyles = 'styl';
  147.         kTypeSoup = 'SOUP';
  148.  
  149. { selectors for WEGetInfo/WESetInfo }
  150.  
  151.         weCharByteHook = 'cbyt';
  152.         weCharTypeHook = 'ctyp';
  153.         weCharToPixelHook = 'c2p ';
  154.         weClickLoop = 'clik';
  155.         weCurrentDrag = 'drag';
  156.         weDrawTextHook = 'draw';
  157.         weLineArray = 'line';
  158.         weLineBreakHook = 'lbrk';
  159.         wePixelToCharHook = 'p2c ';
  160.         wePort = 'port';
  161.         weRefCon = 'refc';
  162.         weRunArray = 'runa';
  163.         weScrollProc = 'scrl';
  164.         weStyleTable = 'styl';
  165.         weText = 'text';
  166.         weTranslateDragHook = 'xdrg';
  167.         weTSMDocumentID = 'tsmd';
  168.         weTSMPostUpdate = 'post';
  169.         weTSMPreUpdate = 'pre ';
  170.  
  171. { possible values returned by WEIntelligentPaste }
  172.  
  173.         weDontAddSpaces = 0;
  174.         weAddSpaceOnLeftSide = -1;
  175.         weAddSpaceOnRightSide = 1;
  176.  
  177. { other miscellaneous constants }
  178.  
  179.         kCaretWidth = 1;                            { width of the caret, in pixels }
  180.         kMinFontSize = 1;                            { minimum valid value for the font size }
  181.         kMaxFontSize = maxint;                { maximum valid value for the font size }
  182.         kOneToOneScaling = $00010001;    { 1:1 scaling ratio }
  183.         kInvalidOffset = -1;                        { used to flag an invalid or nonexistent offset }
  184.         kNullDrag = 0;                                { null or nonexistent drag reference }
  185.         kNullObject = 0;                            { null object reference }
  186.  
  187.     type
  188.  
  189.         WEChars = packed array[0..999999] of Char;
  190.         WECharsPtr = ^WEChars;
  191.         WECharsHandle = ^WECharsPtr;
  192.  
  193.         DoubleByte = packed record
  194.                 firstByte: SignedByte;
  195.                 secondByte: SignedByte;
  196.             end;  { DoubleByte }
  197.  
  198.         WETextStyle = record
  199.                 case Integer of
  200.                     0: (
  201.                             tsFont: Integer;
  202.                             tsFace: SignedByte;
  203.                             tsFlags: SignedByte;
  204.                             tsSize: Integer;
  205.                             tsColor: RGBColor;
  206.                     );
  207.                     1: (
  208.                             tsTEStyle: TextStyle;                    { TextEdit style attributes }
  209.                             tsObject: LongInt;                        { embedded object reference }
  210.                     );
  211.             end;  { WETextStyle }
  212.         WETextStylePtr = ^WETextStyle;
  213.  
  214.         TERunAttributes = record
  215.                 runHeight: Integer;
  216.                 runAscent: Integer;
  217.                 runTEStyle: TextStyle;
  218.             end;  { TERunAttributes }
  219.         TERunAttributesPtr = ^TERunAttributes;
  220.  
  221.         TEStyleScrapElement = record
  222.                 scrpStartChar: LongInt;
  223.                 scrpTEAttrs: TERunAttributes;
  224.             end;  { TEStyleScrapElement }
  225.         TEStyleScrapElementPtr = ^TEStyleScrapElement;
  226.  
  227.         TEStyleScrap = record
  228.                 scrpNStyles: Integer;
  229.                 scrpStyleTab: array[0..0] of TEStyleScrapElement;
  230.             end;
  231.         TEStyleScrapPtr = ^TEStyleScrap;
  232.         TEStyleScrapHandle = ^TEStyleScrapPtr;
  233.  
  234.         WERunAttributes = record
  235.                 case Integer of
  236.                     0: (
  237.                             runHeight: Integer;                { run height (ascent + descent + leading) }
  238.                             runAscent: Integer;            { font ascent }
  239.                             runStyle: WETextStyle;
  240.                     );
  241.                     1: (
  242.                             runTEAttrs: TERunAttributes;
  243.                     );
  244.             end;  { WERunAttributes }
  245.         WERunAttributesPtr = ^WERunAttributes;
  246.  
  247.         WERunInfo = record
  248.                 runStart: LongInt;
  249.                 runEnd: LongInt;
  250.                 runAttrs: WERunAttributes;
  251.             end;  { WERunInfo }
  252.         WERunInfoPtr = ^WERunInfo;
  253.  
  254.         GrafPort1 = record
  255.                 device: Integer;
  256.                 portBits: BitMap;
  257.                 portRect: Rect;
  258.                 visRgn: RgnHandle;
  259.                 clipRgn: RgnHandle;
  260.                 bkPat: Pattern;
  261.                 fillPat: Pattern;
  262.                 pnLoc: Point;
  263.                 pnSize: Point;
  264.                 pnMode: Integer;
  265.                 pnPat: Pattern;
  266.                 pnVis: Integer;
  267.                 txFont: Integer;
  268.                 txFace: SignedByte;
  269.                 filler: SignedByte;
  270.                 txMode: Integer;
  271.                 txSize: Integer;
  272.                 spExtra: Fixed;
  273.                 fgColor: LongInt;
  274.                 bkColor: LongInt;
  275.                 colrBit: Integer;
  276.                 patStretch: Integer;
  277.                 picSave: Handle;
  278.                 rgnSave: Handle;
  279.                 polySave: Handle;
  280.                 grafProcs: QDProcsPtr;
  281.             end;  { GrafPort1 }
  282.         GrafPtr1 = ^GrafPort1;
  283.  
  284.         QDEnvironment = record
  285.                 envPort: GrafPtr;
  286.                 envPen: PenState;
  287.                 envStyle: WETextStyle;
  288.                 envMode: Integer;
  289.             end;  { QDEnvironment }
  290.  
  291.         TEStyleScrapPair = record
  292.                 first: TEStyleScrapElement;
  293.                 second: TEStyleScrapElement;
  294.             end;  { TEStyleScrapPair }
  295.         TEStyleScrapPeek = ^TEStyleScrapPair;
  296.  
  297.         RunArrayElement = record
  298.                 runStart: LongInt;                        { offset to first character in style run }
  299.                 styleIndex: LongInt;                    { index into style table }
  300.             end;  { RunArrayElement }
  301.         RunArrayElementPtr = ^RunArrayElement;
  302.         RunArrayElementHandle = ^RunArrayElementPtr;
  303.  
  304.         RunArrayPair = record
  305.                 first: RunArrayElement;
  306.                 second: RunArrayElement;
  307.             end;  { RunArrayPair }
  308.         RunArrayPeek = ^RunArrayPair;    { useful to "peek" at a portion of the run array }
  309.  
  310.     const
  311.         kRunArrayMaxIndex = (maxLongInt div SizeOf(RunArrayElement)) - 1;
  312.  
  313.     type
  314.         RunArray = array[0..kRunArrayMaxIndex] of RunArrayElement;
  315.         RunArrayPtr = ^RunArray;
  316.         RunArrayHandle = ^RunArrayPtr;
  317.  
  318.         StyleTableElement = record
  319.                 refCount: LongInt;                    { reference count }
  320.                 info: WERunAttributes;                { style information }
  321.             end;  { StyleTableElement }
  322.         StyleTableElementPtr = ^StyleTableElement;
  323.         StyleTableElementHandle = ^StyleTableElementPtr;
  324.  
  325.     const
  326.         kStyleTableMaxIndex = (maxint div SizeOf(StyleTableElement)) - 1;
  327.  
  328.     type
  329.         StyleTable = array[0..kStyleTableMaxIndex] of StyleTableElement;
  330.         StyleTablePtr = ^StyleTable;
  331.         StyleTableHandle = ^StyleTablePtr;
  332.  
  333.         LineRec = record
  334.                 lineStart: LongInt;                    { offset to first character in line }
  335.                 lineOrigin: LongInt;                    { distance from destRect.top, in pixels }
  336.                 lineAscent: Integer;                    { maximum font ascent for this line, in pixels }
  337.                 lineSlop: Integer;                        { extra pixels needed to fill up the line }
  338.                 lineJustAmount: Fixed;                { normalized slop value for justification }
  339.             end;  { LineRec }
  340.         LinePtr = ^LineRec;
  341.         LineHandle = ^LinePtr;
  342.  
  343.         LinePair = record
  344.                 first: LineRec;
  345.                 second: LineRec;
  346.             end;  { LinePair }
  347.         LinePeek = ^LinePair;                    { useful to "peek" at a portion of the line array }
  348.  
  349.     const
  350.         kLineArrayMaxIndex = (maxLongInt div SizeOf(LineRec)) - 1;
  351.  
  352.     type
  353.         LineArray = array[0..kLineArrayMaxIndex] of LineRec;
  354.         LineArrayPtr = ^LineArray;
  355.         LineArrayHandle = ^LineArrayPtr;
  356.  
  357. { Procedure Pointers & UPPs }
  358.  
  359.     type
  360.  
  361. { FUNCTION MyClickLoop(hWE: WEHandle): Boolean; }
  362.         WEClickLoopProcPtr = ProcPtr;
  363.         WEClickLoopUPP = UniversalProcPtr;
  364.  
  365. { PROCEDURE MyScroll(hWE: WEHandle); }
  366.         WEScrollProcPtr = ProcPtr;
  367.         WEScrollUPP = UniversalProcPtr;
  368.  
  369. { PROCEDURE MyTSMPreUpdate(hWE: WEHandle); }
  370.         WETSMPreUpdateProcPtr = ProcPtr;
  371.         WETSMPreUpdateUPP = UniversalProcPtr;
  372.  
  373. { PROCEDURE MyTSMPostUpdate(hWE: WEHandle; fixLength: LongInt; }
  374. {         inputAreaStart, inputAreaEnd: LongInt; pinRangeStart, pinRangeEnd: LongInt); }
  375.         WETSMPostUpdateProcPtr = ProcPtr;
  376.         WETSMPostUpdateUPP = UniversalProcPtr;
  377.  
  378. { FUNCTION MyTranslateDrag (theDrag: DragReference; theItem: ItemReference; }
  379. {         requestedType: FlavorType; putDataHere: Handle): OSErr; }
  380.         WETranslateDragProcPtr = ProcPtr;
  381.         WETranslateDragUPP = UniversalProcPtr;
  382.  
  383. { PROCEDURE MyDrawText (pText: Ptr; textLength: LongInt; slop: Fixed; }
  384. {         styleRunPosition: JustStyleCode; hWE: WEHandle); }
  385.         WEDrawTextProcPtr = ProcPtr;
  386.         WEDrawTextUPP = UniversalProcPtr;
  387.  
  388. { FUNCTION MyPixelToChar (pText: Ptr; textLength: LongInt; slop: Fixed; }
  389. {         VAR pixelWidth: Fixed; VAR edge: SignedByte; }
  390. {         styleRunPosition: JustStyleCode; hPos: Fixed; hWE: WEHandle): LongInt; }
  391.         WEPixelToCharProcPtr = ProcPtr;
  392.         WEPixelToCharUPP = UniversalProcPtr;
  393.  
  394. { FUNCTION MyCharToPixel (pText: Ptr; textLength: LongInt; slop: Fixed; }
  395. {        offset: LongInt; direction: Integer; }
  396. {        styleRunPosition: JustStyleCode; hPos: LongInt; hWE:WEHandle): Integer; }
  397.         WECharToPixelProcPtr = ProcPtr;
  398.         WECharToPixelUPP = UniversalProcPtr;
  399.  
  400. { FUNCTION MyLineBreak (pText: Ptr; textLength: LongInt; }
  401. {        textStart, textEnd: LongInt; VAR textWidth: Fixed; VAR textOffset: LongInt; }
  402. {        hWE: WEHandle): StyledLineBreakCode; }
  403.         WELineBreakProcPtr = ProcPtr;
  404.         WELineBreakUPP = UniversalProcPtr;
  405.  
  406. { PROCEDURE MyWordBreak (pText: Ptr; textLength: Integer; }
  407. {         offset: Integer; edge: SignedByte; VAR breakOffsets: OffsetTable; }
  408. {         script: ScriptCode; hWE: WEHandle); }
  409.         WEWordBreakProcPtr = ProcPtr;
  410.         WEWordBreakUPP = UniversalProcPtr;
  411.  
  412. { FUNCTION MyCharByte (pText: Ptr; textOffset: Integer; }
  413. {         script: ScriptCode; hWE: WEHandle): Integer; }
  414.         WECharByteProcPtr = ProcPtr;
  415.         WECharByteUPP = UniversalProcPtr;
  416.  
  417. { FUNCTION MyCharType (pText: Ptr; textOffset: Integer; }
  418. {         script: ScriptCode; hWE: WEHandle): Integer; }
  419.         WECharTypeProcPtr = ProcPtr;
  420.         WECharTypeUPP = UniversalProcPtr;
  421.  
  422. { UPP proc info }
  423.  
  424.     const
  425.  
  426.         uppWEClickLoopProcInfo = $000000D0;
  427.         uppWEScrollProcInfo = $000000C0;
  428.         uppWETSMPreUpdateProcInfo = $000000C0;
  429.         uppWETSMPostUpdateProcInfo = $0003FFC0;
  430.         uppWETranslateDragProcInfo = $00003FE0;
  431.         uppWEDrawTextProcInfo = $0000EFC0;
  432.         uppWEPixelToCharProcInfo = $003EFFF0;
  433.         uppWECharToPixelProcInfo = $003EBFE0;
  434.         uppWELineBreakProcInfo = $000FFFD0;
  435.         uppWEWordBreakProcInfo = $000EDAC0;
  436.         uppWECharByteProcInfo = $00003AE0;
  437.         uppWECharTypeProcInfo = $00003AE0;
  438.  
  439.     type
  440.  
  441.         WERec = record
  442.                 port: GrafPtr;                                                    { graphics port }
  443.                 hText: Handle;                                                    { handle to the raw text }
  444.                 hLines: LineArrayHandle;                                    { handle to the line array }
  445.                 hStyles: StyleTableHandle;                                { handle to the style table }
  446.                 hRuns: RunArrayHandle;                                    { handle to the style run array }
  447.                 textLength: LongInt;                                            { length of raw text block }
  448.                 nLines: LongInt;                                                { number of lines }
  449.                 nStyles: LongInt;                                                { number of distinct styles in the style table }
  450.                 nRuns: LongInt;                                                { number of style runs in the style run array }
  451.                 viewRect: LongRect;                                            { view rectangle }
  452.                 destRect: LongRect;                                            { destination rectangle }
  453.                 selStart: LongInt;                                                { start of selection range }
  454.                 selEnd: LongInt;                                                { end of selection range }
  455.                 flags: LongInt;                                                    { 32 bits of miscellaneous flags }
  456.                 caretTime: LongInt;                                            { time of most recent caret xoring }
  457.                 clickTime: LongInt;                                            { time of most recent click }
  458.                 clickLoc: LongInt;                                                { byte offset of most recent click }
  459.                 anchorStart: LongInt;                                        { anchor word start }
  460.                 anchorEnd: LongInt;                                            { anchor word end }
  461.                 clickLoop: WEClickLoopUPP;                                { click loop callback }
  462.                 unused1: SignedByte;                                        { unused }
  463.                 clickEdge: SignedByte;                                        { edge of character hit by most recent click }
  464.                 unused2: SignedByte;                                        { unused }
  465.                 firstByte: SignedByte;                                        { first byte of a double-byte character }
  466.                 offscreenPort: GrafPtr;                                        { offscreen graphics world }
  467.                 viewRgn: RgnHandle;                                        { handle to the view region }
  468.                 scrollProc: WEScrollUPP;                                    { scroll callback }
  469.                 clickCount: Integer;                                            { multiple click count }
  470.                 alignment: Integer;                                            { alignment style }
  471.                 refCon: LongInt;                                                { reference value for client use }
  472.                 tsmReference: TSMDocumentID;                        { Text Services Manager document ID }
  473.                 tsmAreaStart: LongInt;                                        { start of active inline input area }
  474.                 tsmAreaEnd: LongInt;                                        { end of active inline input area }
  475.                 tsmPreUpdate: WETSMPreUpdateUPP;                { called before handling a TSM updt event }
  476.                 tsmPostUpdate: WETSMPostUpdateUPP;            { called after handling a TSM updt event }
  477.                 currentDrag: DragReference;                                { reference of drag being tracked by _WEDrag }
  478.                 dragCaretOffset: LongInt;                                    { offset to caret displayed during a drag }
  479.                 translateDragHook: WETranslateDragUPP;            { drag translation hook }
  480.                 hActionStack: Handle;                                        { action stack for undo }
  481.                 modCount: LongInt;                                            { modification count }
  482.                 drawTextHook: WEDrawTextUPP;                        { hook for drawing text }
  483.                 pixelToCharHook: WEPixelToCharUPP;                { hook for hit-testing }
  484.                 charToPixelHook: WECharToPixelUPP;                { hook for locating glyph position }
  485.                 lineBreakHook: WELineBreakUPP;                    { hook for finding line breaks }
  486.                 wordBreakHook: WEWordBreakUPP;                { hook for finding word breaks }
  487.                 charByteHook: WECharByteUPP;                        { hook for finding character byte type }
  488.                 charTypeHook: WECharTypeUPP;                        { hook for finding character type }
  489.                 hObjectHandlerTable: Handle;                            { handle to object handler table for this instance }
  490.                 nullStyle: WERunAttributes;                                { style for null selection }
  491.             end;  { WERec }
  492.         WEPtr = ^WERec;
  493.         WEHandle = ^WEPtr;
  494.  
  495. { NewProc macros }
  496.  
  497.     function NewWEClickLoopProc (userRoutine: WEClickLoopProcPtr): WEClickLoopUPP;
  498. {$IFC NOT GENERATINGCFM}
  499.     inline
  500.         $2E9F;
  501. {$ENDC}
  502.  
  503.     function NewWEScrollProc (userRoutine: WEScrollProcPtr): WEScrollUPP;
  504. {$IFC NOT GENERATINGCFM}
  505.     inline
  506.         $2E9F;
  507. {$ENDC}
  508.  
  509.     function NewWETSMPreUpdateProc (userRoutine: WETSMPreUpdateProcPtr): WETSMPreUpdateUPP;
  510. {$IFC NOT GENERATINGCFM}
  511.     inline
  512.         $2E9F;
  513. {$ENDC}
  514.  
  515.     function NewWETSMPostUpdateProc (userRoutine: WETSMPostUpdateProcPtr): WETSMPostUpdateUPP;
  516. {$IFC NOT GENERATINGCFM}
  517.     inline
  518.         $2E9F;
  519. {$ENDC}
  520.  
  521.     function NewWETranslateDragProc (userRoutine: WETranslateDragProcPtr): WETranslateDragUPP;
  522. {$IFC NOT GENERATINGCFM}
  523.     inline
  524.         $2E9F;
  525. {$ENDC}
  526.  
  527.     function NewWEDrawTextProc (userRoutine: WEDrawTextProcPtr): WEDrawTextUPP;
  528. {$IFC NOT GENERATINGCFM}
  529.     inline
  530.         $2E9F;
  531. {$ENDC}
  532.  
  533.     function NewWEPixelToCharProc (userRoutine: WEPixelToCharProcPtr): WEPixelToCharUPP;
  534. {$IFC NOT GENERATINGCFM}
  535.     inline
  536.         $2E9F;
  537. {$ENDC}
  538.  
  539.     function NewWECharToPixelProc (userRoutine: WECharToPixelProcPtr): WECharToPixelUPP;
  540. {$IFC NOT GENERATINGCFM}
  541.     inline
  542.         $2E9F;
  543. {$ENDC}
  544.  
  545.     function NewWELineBreakProc (userRoutine: WELineBreakProcPtr): WELineBreakUPP;
  546. {$IFC NOT GENERATINGCFM}
  547.     inline
  548.         $2E9F;
  549. {$ENDC}
  550.  
  551.     function NewWEWordBreakProc (userRoutine: WEWordBreakProcPtr): WEWordBreakUPP;
  552. {$IFC NOT GENERATINGCFM}
  553.     inline
  554.         $2E9F;
  555. {$ENDC}
  556.  
  557.     function NewWECharByteProc (userRoutine: WECharByteProcPtr): WECharByteUPP;
  558. {$IFC NOT GENERATINGCFM}
  559.     inline
  560.         $2E9F;
  561. {$ENDC}
  562.  
  563.     function NewWECharTypeProc (userRoutine: WECharTypeProcPtr): WECharTypeUPP;
  564. {$IFC NOT GENERATINGCFM}
  565.     inline
  566.         $2E9F;
  567. {$ENDC}
  568.  
  569. { CallProc macros }
  570.  
  571.     function CallWEClickLoopProc (hWE: WEHandle;
  572.                                     userRoutine: WEClickLoopUPP): Boolean;
  573. {$IFC NOT GENERATINGCFM}
  574.     inline
  575.         $205F, $4E90;
  576. {$ENDC}
  577.  
  578.     procedure CallWEScrollProc (hWE: WEHandle;
  579.                                     userRoutine: WEScrollUPP);
  580. {$IFC NOT GENERATINGCFM}
  581.     inline
  582.         $205F, $4E90;
  583. {$ENDC}
  584.  
  585.     procedure CallWETSMPreUpdateProc (hWE: WEHandle;
  586.                                     userRoutine: WETSMPreUpdateUPP);
  587. {$IFC NOT GENERATINGCFM}
  588.     inline
  589.         $205F, $4E90;
  590. {$ENDC}
  591.  
  592.     procedure CallWETSMPostUpdateProc (hWE: WEHandle;
  593.                                     fixLength: LongInt;
  594.                                     inputAreaStart, inputAreaEnd: LongInt;
  595.                                     pinRangeStart, pinRangeEnd: LongInt;
  596.                                     userRoutine: WETSMPostUpdateUPP);
  597. {$IFC NOT GENERATINGCFM}
  598.     inline
  599.         $205F, $4E90;
  600. {$ENDC}
  601.  
  602.     function CallWETranslateDragProc (theDrag: DragReference;
  603.                                     theItem: ItemReference;
  604.                                     requestedType: FlavorType;
  605.                                     putDataHere: Handle;
  606.                                     userRoutine: WETranslateDragUPP): OSErr;
  607. {$IFC NOT GENERATINGCFM}
  608.     inline
  609.         $205F, $4E90;
  610. {$ENDC}
  611.  
  612.     procedure CallWEDrawTextProc (pText: Ptr;
  613.                                     textLength: LongInt;
  614.                                     slop: Fixed;
  615.                                     styleRunPosition: JustStyleCode;
  616.                                     hWE: WEHandle;
  617.                                     userRoutine: WEDrawTextUPP);
  618. {$IFC NOT GENERATINGCFM}
  619.     inline
  620.         $205F, $4E90;
  621. {$ENDC}
  622.  
  623.     function CallWEPixelToCharProc (pText: Ptr;
  624.                                     textLength: LongInt;
  625.                                     slop: Fixed;
  626.                                     var width: Fixed;
  627.                                     var edge: SignedByte;
  628.                                     styleRunPosition: JustStyleCode;
  629.                                     hPos: Fixed;
  630.                                     hWE: WEHandle;
  631.                                     userRoutine: WEPixelToCharUPP): LongInt;
  632. {$IFC NOT GENERATINGCFM}
  633.     inline
  634.         $205F, $4E90;
  635. {$ENDC}
  636.  
  637.     function CallWECharToPixelProc (pText: Ptr;
  638.                                     textLength: LongInt;
  639.                                     slop: Fixed;
  640.                                     offset: LongInt;
  641.                                     direction: Integer;
  642.                                     styleRunPosition: JustStyleCode;
  643.                                     hPos: LongInt;
  644.                                     hWE: WEHandle;
  645.                                     userRoutine: WECharToPixelUPP): Integer;
  646. {$IFC NOT GENERATINGCFM}
  647.     inline
  648.         $205F, $4E90;
  649. {$ENDC}
  650.  
  651.     function CallWELineBreakProc (pText: Ptr;
  652.                                     textLength: LongInt;
  653.                                     textStart, textEnd: LongInt;
  654.                                     var textWidth: Fixed;
  655.                                     var textOffset: LongInt;
  656.                                     hWE: WEHandle;
  657.                                     userRoutine: WELineBreakUPP): StyledLineBreakCode;
  658. {$IFC NOT GENERATINGCFM}
  659.     inline
  660.         $205F, $4E90;
  661. {$ENDC}
  662.  
  663.     procedure CallWEWordBreakProc (pText: Ptr;
  664.                                     textLength: Integer;
  665.                                     offset: Integer;
  666.                                     edge: SignedByte;
  667.                                     var breakOffsets: OffsetTable;
  668.                                     script: ScriptCode;
  669.                                     hWE: WEHandle;
  670.                                     userRoutine: WEWordBreakUPP);
  671. {$IFC NOT GENERATINGCFM}
  672.     inline
  673.         $205F, $4E90;
  674. {$ENDC}
  675.  
  676.     function CallWECharByteProc (pText: Ptr;
  677.                                     textOffset: Integer;
  678.                                     script: ScriptCode;
  679.                                     hWE: WEHandle;
  680.                                     userRoutine: WECharByteUPP): Integer;
  681. {$IFC NOT GENERATINGCFM}
  682.     inline
  683.         $205F, $4E90;
  684. {$ENDC}
  685.  
  686.     function CallWECharTypeProc (pText: Ptr;
  687.                                     textOffset: Integer;
  688.                                     script: ScriptCode;
  689.                                     hWE: WEHandle;
  690.                                     userRoutine: WECharTypeUPP): Integer;
  691. {$IFC NOT GENERATINGCFM}
  692.     inline
  693.         $205F, $4E90;
  694. {$ENDC}
  695.  
  696.  
  697. { The following declaration lets me pass SignedByte quantities to TextFace. }
  698. { Without this trick, the WASTE.o library would end up containing }
  699. { references to some THINK Pascal runtime routines for set manipulation }
  700. { and such references are very likely to cause link errors when including }
  701. { the library from other development environments. }
  702.  
  703.     procedure __TextFace (face: univ Integer);
  704. {$IFC NOT GENERATINGCFM}
  705.     inline
  706.         $A888;
  707. {$ENDC}
  708.  
  709. { GetQDGlobalsPtr lets me access Quickdraw globals directly from the A5 register }
  710. { without referencing external variables like "qd" (not defined by THINK Pascal) }
  711. { or "thePort" (not defined by newer compilers) }
  712.  
  713.     const
  714.         kQDGlobalsOffset = SizeOf(GrafPtr) - SizeOf(QDGlobals);
  715.  
  716.     type
  717.         QDGlobalsPtr = ^QDGlobals;
  718.  
  719.     function GetQDGlobalsPtr: QDGlobalsPtr;
  720. {$IFC NOT GENERATINGCFM}
  721.     inline
  722.         $2055, $41E8, kQDGlobalsOffset, $2E88;
  723. {$ENDC}
  724.  
  725. implementation
  726. {$IFC GENERATINGCFM}
  727.     uses
  728.         MixedMode;
  729.  
  730. { NewXProc glue needed for the Code Fragment Manager }
  731. { (the CallXProc glue can't be written using Metrowerks Pascal) }
  732.  
  733.     function NewWEClickLoopProc (userRoutine: WEClickLoopProcPtr): WEClickLoopUPP;
  734.     begin
  735.         NewWEClickLoopProc := NewRoutineDescriptor(userRoutine, uppWEClickLoopProcInfo, GetCurrentArchitecture);
  736.     end;  { NewWEClickLoopProc }
  737.  
  738.     function NewWEScrollProc (userRoutine: WEScrollProcPtr): WEScrollUPP;
  739.     begin
  740.         NewWEScrollProc := NewRoutineDescriptor(userRoutine, uppWEScrollProcInfo, GetCurrentArchitecture);
  741.     end;  { NewWEScrollProc }
  742.  
  743.     function NewWETSMPreUpdateProc (userRoutine: WETSMPreUpdateProcPtr): WETSMPreUpdateUPP;
  744.     begin
  745.         NewWETSMPreUpdateProc := NewRoutineDescriptor(userRoutine, uppWETSMPreUpdateProcInfo, GetCurrentArchitecture);
  746.     end;  { NewWETSMPreUpdateProc }
  747.  
  748.     function NewWETSMPostUpdateProc (userRoutine: WETSMPostUpdateProcPtr): WETSMPostUpdateUPP;
  749.     begin
  750.         NewWETSMPostUpdateProc := NewRoutineDescriptor(userRoutine, uppWETSMPostUpdateProcInfo, GetCurrentArchitecture);
  751.     end;  { NewWETSMPostUpdateProc }
  752.  
  753.     function NewWETranslateDragProc (userRoutine: WETranslateDragProcPtr): WETranslateDragUPP;
  754.     begin
  755.         NewWETranslateDragProc := NewRoutineDescriptor(userRoutine, uppWETranslateDragProcInfo, GetCurrentArchitecture);
  756.     end;  { NewWETranslateDragProc }
  757.  
  758.     function NewWEDrawTextProc (userRoutine: WEDrawTextProcPtr): WEDrawTextUPP;
  759.     begin
  760.         NewWEDrawTextProc := NewRoutineDescriptor(userRoutine, uppWEDrawTextProcInfo, GetCurrentArchitecture);
  761.     end;  { NewWEDrawTextProc }
  762.  
  763.     function NewWEPixelToCharProc (userRoutine: WEPixelToCharProcPtr): WEPixelToCharUPP;
  764.     begin
  765.         NewWEPixelToCharProc := NewRoutineDescriptor(userRoutine, uppWEPixelToCharProcInfo, GetCurrentArchitecture);
  766.     end;  { NewWEPixelToCharProc }
  767.  
  768.     function NewWECharToPixelProc (userRoutine: WECharToPixelProcPtr): WECharToPixelUPP;
  769.     begin
  770.         NewWECharToPixelProc := NewRoutineDescriptor(userRoutine, uppWECharToPixelProcInfo, GetCurrentArchitecture);
  771.     end;  { NewWECharToPixelProc }
  772.  
  773.     function NewWELineBreakProc (userRoutine: WELineBreakProcPtr): WELineBreakUPP;
  774.     begin
  775.         NewWELineBreakProc := NewRoutineDescriptor(userRoutine, uppWELineBreakProcInfo, GetCurrentArchitecture);
  776.     end;  { NewWELineBreakProc }
  777.  
  778.     function NewWEWordBreakProc (userRoutine: WEWordBreakProcPtr): WEWordBreakUPP;
  779.     begin
  780.         NewWEWordBreakProc := NewRoutineDescriptor(userRoutine, uppWEWordBreakProcInfo, GetCurrentArchitecture);
  781.     end;  { NewWEWordBreakProc }
  782.  
  783.     function NewWECharByteProc (userRoutine: WECharByteProcPtr): WECharByteUPP;
  784.     begin
  785.         NewWECharByteProc := NewRoutineDescriptor(userRoutine, uppWECharByteProcInfo, GetCurrentArchitecture);
  786.     end;  { NewWECharByteProc }
  787.  
  788.     function NewWECharTypeProc (userRoutine: WECharTypeProcPtr): WECharTypeUPP;
  789.     begin
  790.         NewWECharTypeProc := NewRoutineDescriptor(userRoutine, uppWECharTypeProcInfo, GetCurrentArchitecture);
  791.     end;  { NewWECharTypeProc }
  792.  
  793.     procedure __TextFace (face: univ Integer);
  794.     begin
  795.         TextFace(face);
  796.     end;  { __TextFace }
  797.  
  798.     function GetQDGlobalsPtr: QDGlobalsPtr;
  799.     begin
  800.         GetQDGlobalsPtr := @qd;
  801.     end;  { GetQDGlobalsPtr }
  802.  
  803. {$ENDC}
  804. end.